package com.bayair.doctor.utils;

import android.graphics.Color;

import com.bayair.doctor.App;
import com.bayair.doctor.R;

/**
 *  从数组中取出颜色
 */
public class ColorFromArray {

    private static final String TAG = "ColorUtils";

    private final String[] mArray;

    private ColorFromArray() {
        //获取xml资源文件
        mArray = App.getContext().getResources().getStringArray(R.array.color_value);
    }

    private static ColorFromArray mColorUtils = new ColorFromArray();

    public static ColorFromArray newInstance() {
        return mColorUtils;
    }


    public int getPositionColor(int position) {
        int index = (position % mArray.length);
        if (index < 0 || index >= mArray.length) {
            index = 0;
        }
        return Color.parseColor(mArray[index]);
    }
}
